package q1;

import java.util.ArrayList;
import java.util.List;

import com.alibaba.fastjson.JSON;

/**
 * 节点
 * @author：涂有
 * @date 2017年12月1日 下午5:31:41
 */
public class Node {

	private int id;
	private int parentId;
	private String code;
	private List<Node> children = new ArrayList<>();
	
	public Node(){}
	
	public Node(int id, int parentId, String code) {
		super();
		this.id = id;
		this.parentId = parentId;
		this.code = code;
	}
	public int getId() {
		return id;
	}
	public void setId(int id) {
		this.id = id;
	}
	public int getParentId() {
		return parentId;
	}
	public void setParentId(int parentId) {
		this.parentId = parentId;
	}
	public String getCode() {
		return code;
	}
	public void setCode(String code) {
		this.code = code;
	}
	public List<Node> getChildren() {
		return children;
	}
	public void setChildren(List<Node> children) {
		this.children = children;
	}
	public void addChild(Node child) {
		this.children.add(child);
	}

	@Override
	public String toString() {
		return JSON.toJSONString(this);
	}
}
